package com.qiangesoft.blog.file.core;

import com.qiangesoft.blog.file.model.FileInfoVo;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List;

/**
 * 文件存储策略接口
 *
 * @author qiange
 * @date 2023-04-26
 */
public interface FileStoreStrategy {

    /**
     * 上传文件
     *
     * @param file
     * @return
     * @throws Exception
     */
    FileInfoVo uploadFile(MultipartFile file) throws Exception;

    /**
     * 上传文件
     *
     * @param file
     * @param path
     * @return
     * @throws Exception
     */
    FileInfoVo uploadFile(MultipartFile file, String path) throws Exception;

    /**
     * 上传文件
     *
     * @param inputStream
     * @param contentType
     * @return
     * @throws Exception
     */
    FileInfoVo uploadFile(InputStream inputStream, String contentType) throws Exception;

    /**
     * 上传文件
     *
     * @param inputStream
     * @param contentType
     * @param path
     * @return
     * @throws Exception
     */
    FileInfoVo uploadFile(InputStream inputStream, String contentType, String path) throws Exception;

    /**
     * 批量上传文件
     *
     * @param files
     * @return
     * @throws Exception
     */
    List<FileInfoVo> batchUploadFile(MultipartFile[] files) throws Exception;

    /**
     * 批量上传文件
     *
     * @param files
     * @param path
     * @return
     * @throws Exception
     */
    List<FileInfoVo> batchUploadFile(MultipartFile[] files, String path) throws Exception;

    /**
     * 下载文件
     *
     * @param key 文件路径或者文件标识
     * @throws Exception
     */
    void downloadFile(String key, HttpServletRequest request, HttpServletResponse response) throws Exception;

    /**
     * 删除文件
     *
     * @param key 文件路径或者文件标识
     * @throws Exception
     */
    void deleteFile(String key) throws Exception;
}
